package com.dy.lock.screen.job;

import java.util.Date;
import java.util.Map;

import org.apache.log4j.Logger;

import com.dy.lock.screen.constants.Constant;
import com.dy.lock.screen.constants.GtPushCodeDes;
import com.dy.lock.screen.utils.CommonUtil;
import com.dy.lock.screen.utils.GtPushUtil;
import com.dy.lock.screen.vo.GtPushMessageVo;

/**
 * 定时推送消息任务
 * 
 * @author XIANG
 * 
 */
public class TimerJob {

	private static Logger log = Logger.getLogger(TimerJob.class);

	/**
	 * 定时推送消息
	 */
	public void sendMessageTimerJob() {
		GtPushMessageVo gtVo = new GtPushMessageVo();
		gtVo.setCode(Integer.parseInt(GtPushCodeDes.TIMER_SIGN_IN_MESSAGE
				.getCode()));
		gtVo.setMessageContent(GtPushCodeDes.TIMER_SIGN_IN_MESSAGE
				.getDescription());
		gtVo.setMessageTime(new Date());
		gtVo.setMessageTitle("签到信息");
		try {
			Map<String, Object> ret = GtPushUtil.pushToApp(null, null, null,
					null, CommonUtil.gson().toJson(gtVo));
			log.info("全量定时推送服务器返回结果：" + ret.toString());
			String result = (String) ret.get("result");
			if (Constant.OK.equalsIgnoreCase(result)) {
				log.info("全量消息推送成功：" + GtPushUtil.map.get(result));
			} else {
				log.error("全量消息推送失败：" + GtPushUtil.map.get(result));
			}

		} catch (Exception e) {
			log.error("全量消息推送失败：", e);
		}

	}
}
